﻿module WingBeats.Xml.Xss

open Microsoft.Security.Application

/// Safely encode a string for inclusion in an HTML attribute.
let attrEncode s =
    AntiXss.HtmlAttributeEncode(s)

/// Safely encode a string for inclusion in HTML content.
let htmlEncode s =
    AntiXss.HtmlEncode(s)

/// Safely encode a string for inclusion in JavaScript content. Adds quotes for you.
let jsEncode s =
    AntiXss.JavaScriptEncode(s)

// add extension methods to strings
type System.String with
    member x.HtmlEncode() =
        AntiXss.HtmlEncode(x)
    member x.HtmlAttributeEncode() =
        AntiXss.HtmlAttributeEncode(x)
    member x.JavaScriptEncode() =
        AntiXss.JavaScriptEncode(x)